<template>
    <div id="contentMargin">
        info{{id}}
        <div id="desc">
            <div class="title">
                <h4>{{photoinfo.title}}</h4>
                <p>{{photoinfo.add_time | datefmt('YYYY-MM-DD HH:mm:ss')}}&nbsp;&nbsp;&nbsp;&nbsp; {{photoinfo.click}}次浏览</p>
                <p class="line"></p>
            </div>
            <div class="imgs">
                <div class="mui-content">
                    <ul class="mui-table-view mui-grid-view mui-grid-9">
                        <li v-for="(item, index) in list"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">

                                <img class="preview-img"  :src="item.src" height="100" @click="$preview.open(index, list)" >

                        </li>

                    </ul>
                </div>
            </div>
                <p v-text="photoinfo.content"></p>
        </div>

        <div id="comment">
            <comment :id="id"></comment>
        </div>
    </div>
</template>
<script>
    import comment from '../subcom/comment.vue';
    import common from '../../kits/common.js'
    export default {
        components:{
            comment
        },
        data(){
            return  {
                id:0,
                list: [
                    {
                    src: '../../../statics/imgs/img1.jpg',
                    w: 600,
                    h: 400
                }, {
                    src: '../../../statics/imgs/img2.jpg',
                    w: 600,
                    h: 400
                }, {
                    src: '../../../statics/imgs/img3.jpg',
                    w: 600,
                    h: 400
                }, {
                    src: '../../../statics/imgs/img4.jpg',
                    w: 600,
                    h: 400
                }, {
                    src: '../../../statics/imgs/img5.jpg',
                    w: 600,
                    h: 400
                }, {
                    src: '../../../statics/imgs/img1.jpg',
                    w: 600,
                    h: 400
                }
                ],
                photoinfo:{
                    "id":14,
                    "title":"这是图片详情页面的标题",
                    "click":2,
                    "add_time":"2017-04-14T04:32:06.000Z",
                    "content":"这是图片详情大页面的内容"
                }
            }
        },
        created(){
            this.id = this.$route.params.id;
            this.getinfo();
            this.getimgs();
        },
        methods:{
            getimgs(){
                var url =common.apidomain+'api/...'+this.id;
                this.$http.get(url).then(res=>{
                    if(res.body.status!=0){
                        alert(res.body.message);
                        return;
                    }
                    res.body.message.forEach(item=>{
                        var img = document.createElement('img');
                        img.src = item.src;
                       item.w = img.width;
                       item.h = img.height;
                    });
                    this.list = res.body.message;
                })
            },
            getinfo(){
                var url=common.apidomain+'/api/..'+this.id;
                this.$http.get(url).then(res=>{
                    if(res.body.status!=0){
                        alert(res.body.message);
                        return;
                    }
                    this.photoinfo = res.body.message[0];
                })
            }
        }
    }
</script>
<style scoped>
    #desc{
        padding: 10px;
    }
    #desc .title h4{
        color: #007aff;
    }
    #desc .title p{
        margin-top: 10px;
        color: rgba(0,0,0,0.3);
    }
    #desc .title p.line{
        width: 100%;
        height: 1px;
        border-bottom:1px solid rgba(0,0,0,0.5);
    }
    .mui-content img {
        width: 100px;
        height: 100px;
        cursor: pointer;
    }
    .mui-content, .mui-content ul {
        border-top: 0;
        border-left: 0;
        background-color: white;
    }

    .mui-grid-view.mui-grid-9 .mui-table-view-cell {
        border-right: 0;
        border-bottom: 0;
    }

</style>